﻿
<c:if test="${obj.pager.recordCount>0}">
	<c:set var="cond" value="" />
	<c:forEach var="oneItem" items="${formdata}">
		<c:set var="cond" value="${cond}${oneItem.key}=${oneItem.value}&" />
	</c:forEach>

	<c:set var="pager" value="${obj.pager}" />
	<c:set var="cp" value="${pager.pageNumber}" />
	<c:set var="mp" value="${pager.pageCount}" />

	<div class='pagination'>
		符合条件共<b>${pager.recordCount}</b>条记录
		<c:if test="${cp==1}">
			<span class='curpage'>首页</span>
		</c:if>
		<c:if test="${cp!=1}">
			<a href="?p=1&${cond}">首页</a>
		</c:if>
		<c:set var="beginPage" value="${cp-5}" />
		<c:if test="${beginPage<1}">
			<c:set var="beginPage" value="1" />
		</c:if>
		<c:set var="endPage" value="${cp+5}" />
		<c:if test="${endPage>mp}">
			<c:set var="endPage" value="${mp}" />
		</c:if>
		<c:if test="${cp==1}">
			上一页
		</c:if>
		<c:if test="${cp!=1}">
			<a href="?p=${cp-1}&${cond}">上一页</a>
		</c:if>

		<c:forEach begin="${beginPage}" end="${endPage}" var="pp">
			<c:if test="${cp==pp}">
				<span class='curpage'>${pp}</span>
			</c:if>
			<c:if test="${cp!=pp}">
				<a href="?p=${pp}&${cond}">${pp}</a>
			</c:if>
		</c:forEach>
		<c:if test="${cp==mp}">
		下一页
		</c:if>
		<c:if test="${cp!=mp}">
			<a href="?p=${cp+1}&${cond}">下一页</a>
		</c:if>
		<c:if test="${cp==mp}">
			<span class='curpage'>尾页</span>
		</c:if>
		<c:if test="${cp!=mp}">
			<a href="?p=${mp}&${cond}">尾页</a>
		</c:if>
		<input type="text" id="goPage" size="2" maxLength="4" onkeypress="if(event.keyCode == 13) doJump();" onkeyup="this.value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />
		<input type="button" value="Go" onclick="doJump()"/>
	</div>
	<script>
		function doJump(){
			var x = $("#goPage").val();
			if(x.length==0){
				alert("请输入页数。");
				$("#goPage").focus();
				return;
			}
			if(parseInt(x)>parseInt('${mp}')){
				alert("输入的数字超过了最大页数。");
				$("#goPage").focus();
				return;
			}
			window.location="?p=" +x + "&${cond}";
		}
	</script>
</c:if>